/*jslint indent: 4*/

/*Analogue 1.11.12, Copyright (c) 2011 Analogue Web Design LLC, all rights reserved.*/
var analogue = (function (document, push, root, slice, window) {
    'use strict';

    if (typeof Array.prototype.indexOf !== 'function') {
        Array.prototype.indexOf = function indexOf(item, i) {
            /*jslint bitwise: true*/
            var ii = this.length >>> 0;
            if (ii > 0) {
                i = isNaN(Number(i)) ? 0 : i < 0 ? Math.max(0, ii + i) : i;
                while (i < ii) {
                    if (this.hasOwnProperty(i) && this[i] === item) {
                        return i;
                    }
                    i += 1;
                }
            }
            return -1;
        };
    }

    if (!Function.prototype.bind) {
        Function.prototype.bind = function bind(context) {
            /*jslint evil: true*/
            if (typeof this !== 'function') {
                throw new TypeError('Function.prototype.bind called on incompatible Object');
            }
            var args = slice.call(arguments, 1),
                bound,
                NoOp = function () {},
                method = this;
            bound = new Function('args,NoOp,slice,method,context', 'function bound(' + args.join(', ') + '){var isConstruct=this instanceof bound,result,toBind=context;if(isConstruct){NoOp.prototype=method.prototype;toBind=new NoOp()}result=method.apply(toBind,args.concat(slice.call(arguments)));return isConstruct&&(typeof result===\'object\'&&!result)?toBind:result}bound.prototype=method.prototype;return bound;')(args, NoOp, slice, method, context);
            bound.call = bound.apply = function () {
                return method.apply(context, args.concat(slice.call(arguments, 1)));
            };
            return bound;
        };
    }

    var build = new Date(1324148363976),

        cache = {
            events: [],
            guid: 1E3,
            regex: {
                get: function (key) {
                    return this.store[key] || null;
                },
                set: function (key, value) {
                    this.store[key] = value;
                    return value;
                },
                store: {}
            },
            wrappers: {}
        },

        contains = root.contains ? function (context, node) {
            return context.contains(node);
        } : root.compareDocumentPosition ? function (context, node) {
            /*jslint bitwise: true*/
            return !!(context.compareDocumentPosition(node) & 16);
        } : function (context, node) {
            do {
                if (node === context) {
                    return true;
                }
                node = node.parentNode;
            } while (node);
            return false;
        },

        detect = (function () {
            var a,
                canBubble = root.attachEvent ? function (div, event) {
                    event = 'on' + event;
                    var bubbles = typeof div[event] !== 'undefined';
                    if (!bubbles) {
                        div.setAttribute(event, 'return;');
                        bubbles = typeof div[event] === 'function';
                    }
                    return bubbles;
                } : function () {
                    return true;
                },
                div = document.createElement('div'),
                id = 'id' + new Date().getTime(),
                input = document.createElement('input'),
                option = document.createElement('option');
            root.className = 'hasJs';
            div.id = 'length';
            div.innerHTML = '<a class="a ab" href="/a" name="' + id + '" style="color:red;float:left;opacity:.5">a</a><a class="ab a"></a><b class=""></b>';
            a = div.getElementsByTagName('a')[0];
            input.setAttribute('value', '5');
            option.setAttribute('selected', 'selected');
            root.insertBefore(div, root.firstChild);
            try {
                return {
                    addEvent: root.addEventListener ? 'addEventListener' : 'attachEvent',
                    changeBubbles: canBubble(div, 'change'),
                    children: typeof root.children !== 'undefined',
                    cssFloat: !!a.style.cssFloat ? 'cssFloat' : 'styleFloat',
                    eventPrefix: root.addEventListener ? '' : 'on',
                    filters: typeof div.filters !== 'undefined',
                    getAttribute: a.getAttribute('href') === '/a' && input.defaultValue !== 5,
                    getComputedStyle: typeof window.getComputedStyle !== 'undefined',
                    getElementById: !document.getElementById(id),
                    getElementsByClassName: root.getElementsByClassName ? (function () {
                        var results = div.getElementsByClassName('a').length === 2;
                        if (results) {
                            a.className = 'b';
                            results = div.getElementsByClassName('a').length === 1;
                        }
                        return results;
                    }()) : false,
                    matchesSelector: (function () {
                        var i,
                            prefix = ['m', 'khtmlM', 'oM', 'mozM', 'msM', 'webkitM'],
                            suffix = 'atchesSelector';
                        for (i = prefix.length - 1; i > -1; i -= 1) {
                            if (typeof root[prefix[i] + suffix] !== 'undefined') {
                                return prefix[i] + suffix;
                            }
                        }
                        return null;
                    }()),
                    msie: /*@cc_on!@*/false,
                    opacity: /^0\.5$/.test(a.style.opacity),
                    querySelector: root.querySelector ? (function () {
                        var pattern = [];
                        try {
                            if (div.querySelectorAll('b[class*=""]').length === 1) {
                                pattern.push('[*\\^$]=\\s*(?:""|' + "'')");
                            }
                        } catch (e) {}
                        if (!option.hasAttribute('selected')) {
                            pattern.push('\\[\\s*(?:checked|disabled|ismap|multiple|readonly|selected|value)');
                        }
                        return pattern.length ? new RegExp(pattern.join('|')) : {
                            test: function () {
                                return false;
                            }
                        };
                    }()) : {
                        test: function () {
                            return true;
                        }
                    },
                    removeEvent: root.removeEventListener ? 'removeEventListener' : 'detachEvent',
                    resetBubbles: canBubble(div, 'reset'),
                    selectBubbles: canBubble(div, 'select'),
                    slice: (function () {
                        try {
                            return !!slice.call(div.childNodes, 0)[0].nodeType;
                        } catch (e) {}
                        return false;
                    }()),
                    style: /red/.test(a.getAttribute('style')),
                    submitBubbles: canBubble(div, 'submit'),
                    textContent: a.textContent === 'a' ? 'textContent' : 'innerText',
                    traversalApi: typeof root.nextElementSibling !== 'undefined' && typeof root.lastElementChild !== 'undefined'
                };
            } finally {
                root.removeChild(div);
                a = div = input = option = null;
            }
        }()),

        dollar = window.$,

        domContentLoaded = false,

        DOMArray = function () {},

        DOMFragment = (function () {
            var createFragment = function (html) {
                    var div = document.createElement('div'),
                        fragment = document.createDocumentFragment(),
                        i,
                        ii;
                    div.innerHTML = html;
                    for (i = 0, ii = div.childNodes.length; i < ii; i += 1) {
                        fragment.appendChild(div.childNodes[i].cloneNode(true));
                    }
                    try {
                        return fragment;
                    } finally {
                        div = fragment = null;
                    }
                };
            return function (html) {
                this[0] = createFragment(html);
                this.length = 1;
            };
        }()),

        DOMWrapper = function (element) {
            this[0] = element;
            this.length = 1;
            this.tagName = element.nodeName.toUpperCase();
        },

        escapeRegExp = function (string) {
            return string.replace(/([.*+?\^=!:${}()|\[\]\/\\])/g, '\\$1');
        },

        events = (function () {
            var capture = {
                    blur: typeof root.ondeactivate !== 'undefined' ? 'deactivate' : 'blur',
                    focus: typeof root.onactivate !== 'undefined' ? 'activate' : 'focus'
                },
                delegateEvent = function (listener, selector) {
                    return function (event) {
                        if (analogue.match(event.target, selector)) {
                            listener.apply(event.target, arguments);
                        }
                    };
                },
                fixEvent = (function () {
                    var properties = ['altKey', 'bubbles', 'button', 'cancelable', 'charCode', 'clientX', 'clientY', 'ctrlKey', 'detail', 'eventPhase', 'keyCode', 'pageX', 'pageY', 'relatedTarget', 'screenX', 'screenY', 'shiftKey', 'type', 'view', 'which'];
                    return function (element, source) {
                        var event = {},
                            i,
                            type = source.type;
                        if (source.original) {
                            return source;
                        }
                        event.currentTarget = source.currentTarget || element;
                        event.metaKey = source.metaKey || source.ctrlKey;
                        event.original = source;
                        event.preventDefault = function () {
                            if (source.preventDefault) {
                                source.preventDefault();
                            }
                            event.returnValue = source.returnValue = false;
                            return event;
                        };
                        event.stopPropagation = function () {
                            if (source.stopPropagation) {
                                source.stopPropagation();
                            }
                            event.cancelBubble = source.cancelBubble = true;
                            return event;
                        };
                        event.target = source.target ? (source.target.nodeType === 3 ? source.target.parentNode : source.target) : source.srcElement || element;
                        event.timeStamp = new Date().getTime();
                        if (type.indexOf('key') !== -1) {
                            event.which = source.which || source.keyCode;
                        } else if (/^mouse|click$/i.test(type)) {
                            event.pageX = source.pageX || source.clientX + root.scrollLeft - (root.clientLeft || 0);
                            event.pageY = source.pageY || source.clientY + root.scrollTop - (root.clientTop || 0);
                            if (/(?:over|out)$/.test(type)) {
                                event.relatedTarget = source.relatedTarget || type === 'mouseover' ? event.fromElement : event.toElement;
                            }
                            event.which = source.which || (source.button === 1 ? 1 : (source.button === 4 ? 2 : (source.button === 2 ? 3 : 0)));
                        }
                        for (i = properties.length - 1; i > -1; i -= 1) {
                            if (typeof event[properties[i]] === 'undefined') {
                                event[properties[i]] = source[properties[i]];
                            }
                        }
                        return event;
                    };
                }()),
                handleEvent = function (element, event) {
                    /*jslint continue: true*/
                    var queue = slice.call(element.events[event.type]),
                        listener;
                    while (queue.length) {
                        listener = queue.shift();
                        try {
                            (listener.delegate || listener).call(element[0], event);
                        } finally {
                            continue;
                        }
                    }
                },
                handler = function (event) {
                    handleEvent(this, fixEvent(this[0], event));
                },
                relay = function (type) {
                    return (/^(?:change|select|submit|reset)$/i.test(type) && !detect[type + 'Bubbles']);
                },
                relayEvent = function (method, selector, type, listener) {
                    if (/^(?:change|select)$/i.test(type)) {
                        return this[method](selector, 'focus', function () {
                            analogue(this).removeEvent(type, listener).addEvent(type, listener);
                        })[method](selector, 'blur', function () {
                            analogue(this).removeEvent(type, listener);
                        });
                    }
                    selector += ' *';
                    return this[method](selector, 'focus', function () {
                        analogue(this).parent('form').removeEvent(type, listener).addEvent(type, listener);
                    })[method](selector, 'blur', function () {
                        analogue(this).parent('form').removeEvent(type, listener);
                    });
                };
            return {
                addDelegate: function (selector, type, listener) {
                    if (this[0] === document || this[0] === window) {
                        analogue(root).addDelegate(selector, type, listener);
                        return this;
                    }
                    var i,
                        ii,
                        types = type.split(' ');
                    for (i = 0, ii = types.length; i < ii; i += 1) {
                        type = types[i];
                        if (relay(type)) {
                            relayEvent.call(this, 'addDelegate', selector, type, listener);
                        } else {
                            type = capture[type] || type;
                            listener.delegate = listener.delegate || delegateEvent(listener, selector);
                            this.addEvent(type, listener);
                        }
                    }
                    return this;
                },
                addEvent: function (type, listener) {
                    this.events = this.events || {};
                    var i,
                        ii,
                        types = type.split(' ');
                    for (i = 0, ii = types.length; i < ii; i += 1) {
                        type = types[i];
                        if (this.events[type] && this.events[type].indexOf(listener) === -1) {
                            this.events[type].push(listener);
                        } else {
                            this.events[type] = [listener];
                            if (!this.events.handler) {
                                this.events.handler = handler.bind(this);
                            }
                            this[0][detect.addEvent](detect.eventPrefix + type, this.events.handler, /^(?:blur|focus)$/i.test(type));
                            this.events[type].key = cache.events.push([this[0], type, this.events.handler]) - 1;
                        }
                    }
                    return this;
                },
                removeDelegate: function (selector, type, listener) {
                    if (this[0] === document || this[0] === window) {
                        analogue(root).removeDelegate(selector, type, listener);
                        return this;
                    }
                    if (this.events) {
                        var i,
                            ii,
                            types = type.split(' ');
                        for (i = 0, ii = types.length; i < ii; i += 1) {
                            type = types[i];
                            if (relay(type)) {
                                relayEvent.call(this, 'removeDelegate', selector, type, listener);
                            } else {
                                type = capture[type] || type;
                                this.removeEvent(type, listener);
                            }
                        }
                    }
                    return this;
                },
                removeEvent: function (type, listener) {
                    if (this.events) {
                        var e,
                            i,
                            ii,
                            types = type.split(' ');
                        for (i = 0, ii = types.length; i < ii; i += 1) {
                            type = types[i];
                            if (this.events[type]) {
                                e = this.events[type].indexOf(listener);
                                if (e > -1) {
                                    if (this.events[type].length === 1) {
                                        this[0][detect.removeEvent](detect.eventPrefix + type, this.events.handler, /^(?:blur|focus)$/i.test(type));
                                        cache.events.splice(this.events[type].key, 1);
                                        delete this.events[type];
                                    } else {
                                        this.events[type].splice(e, 1);
                                    }
                                }
                            }
                        }
                    }
                    return this;
                },
                triggerEvent: root.dispatchEvent ? function (type, which) {
                    var charCode = 0,
                        event = null,
                        keyCode = 0;
                    if (/^mouse|click$/i.test(type)) {
                        event = document.createEvent('MouseEvents');
                        if (event.initMouseEvent) {
                            event.initMouseEvent(type, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, which || 0, null);
                        } else {
                            event = document.createEvent('UIEvents');
                            event.initEvent(type, true, true);
                            event.button = which || 0;
                        }
                    } else if (/key(?:down|press|up)/i.test(type)) {
                        if (which) {
                            which = typeof which === 'number' ? which : which.charCodeAt(0);
                            if (type === 'keypress') {
                                if ((which > 64 && which < 91) || (which > 96 && which < 123)) {
                                    charCode = which;
                                } else {
                                    keyCode = which;
                                }
                            } else {
                                keyCode = which;
                            }
                        }
                        try {
                            event = document.createEvent('KeyEvents');
                            event.initKeyEvent(type, true, true, window, false, false, false, false, keyCode, charCode);
                        } catch (e) {
                            try {
                                event = document.createEvent('Events');
                            } catch (ex) {
                                event = document.createEvent('UIEvents');
                            } finally {
                                event.initEvent(type, true, true);
                                event.keyCode = keyCode;
                                event.charCode = charCode;
                                event.which = which || 0;
                            }
                        }
                    } else {
                        event = document.createEvent('HTMLEvents');
                        event.initEvent(type, true, true);
                    }
                    return this[0].dispatchEvent(event);
                } : function (type, which) {
                    var event = document.createEventObject();
                    if (/^mouse|click$/i.test(type)) {
                        event.button = (which === 0 ? 1 : (which === 1 ? 4 : (which === 2 ? 2 : 0)));
                    } else if (/key(?:down|press|up)/i.test(type)) {
                        event.keyCode = (which ? (typeof which === 'number' ? which : which.charCodeAt(0)) : 0);
                    }
                    event.type = type;
                    if (this[0][type]) {
                        this[0][type]();
                    }
                    return this[0].fireEvent('on' + type, event);
                }
            };
        }()),

        extend = function (object, source) {
            var i;
            for (i in source) {
                if (source.hasOwnProperty(i) && !object[i]) {
                    object[i] = source[i];
                }
            }
            return object;
        },

        getElementById = detect.getElementById ? function (id) {
            return document.getElementById(id);
        } : function (id) {
            var element = document.getElementById(id),
                elements,
                i = 0;
            if (element) {
                if (element.id === id) {
                    return element;
                }
                elements = document.getElementsByName(id);
                while (elements[i]) {
                    if (elements[i].getAttribute('id') === id) {
                        return elements[i];
                    }
                    i += 1;
                }
            }
            return null;
        },

        makeArray = function (elements) {
            var collection = new DOMArray(),
                i = 0;
            if (detect.slice) {
                push.apply(collection, slice.call(elements));
            } else {
                while (elements[i]) {
                    collection.push(elements[i]);
                    i += 1;
                }
            }
            return collection;
        },

        methods = (function () {
            var booleans = {
                    checked: 1,
                    disabled: 1,
                    isMap: 1,
                    multiple: 1,
                    readOnly: 1,
                    selected: 1
                },
                getAttributeValue = function (node) {
                    return node && node.specified ? node.nodeValue : null;
                },
                normalize = {
                    accesskey: 'accessKey',
                    cellpadding: 'cellPadding',
                    cellspacing: 'cellSpacing',
                    colspan: 'colSpan',
                    encoding: 'enctype',
                    frameborder: 'frameBorder',
                    ismap: 'isMap',
                    maxlength: 'maxLength',
                    readonly: 'readOnly',
                    rowspan: 'rowSpan',
                    tabindex: 'tabIndex',
                    valign: 'vAlign',
                    usemap: 'useMap'
                },
                properties = {
                    'class': 'className',
                    'float': detect.cssFloat,
                    'for': 'htmlFor',
                    html: 'innerHTML',
                    text: detect.textContent,
                    value: 'value'
                },
                set = function (name, value) {
                    if (this.nodeType === 1) {
                        name = normalize[name.toLowerCase()] || name;
                        if (value === false || value === null) {
                            if (properties[name]) {
                                this[properties[name]] = '';
                            } else if (booleans[name]) {
                                this[name] = false;
                            } else {
                                this.removeAttribute(name);
                            }
                        } else if (name === 'style' && !detect.style) {
                            this.style.cssText = value;
                        } else if (properties[name]) {
                            this[properties[name]] = value;
                        } else if (booleans[name]) {
                            this[name] = true;
                        } else {
                            this.setAttribute(name, value);
                        }
                    } else {
                        this[name] = value;
                    }
                },
                uris = {
                    action: 1,
                    data: 1,
                    href: 1,
                    lowsrc: 1,
                    src: 1,
                    useMap: 1
                };
            return {
                get: function (name) {
                    var node = this[0] || this;
                    if (node.nodeType === 1) {
                        name = normalize[name.toLowerCase()] || name;
                        if (name === 'style') {
                            return detect.style ? node.getAttribute('style') || null : String(node.style.cssText) || null;
                        }
                        if (booleans[name]) {
                            return node[name] ? name : null;
                        }
                        if (properties[name] || name === 'type') {
                            return node[properties[name] || name] || null;
                        }
                        if (uris[name]) {
                            return node.getAttribute(name, 2) || null;
                        }
                        return getAttributeValue(node.getAttributeNode(name));
                    }
                    return node[name] || null;
                },
                set: function (name, value) {
                    var i;
                    if (typeof name === 'object') {
                        for (i in name) {
                            if (name.hasOwnProperty(i)) {
                                set.call(this[0], i, name[i]);
                            }
                        }
                    } else {
                        set.call(this[0], name, value);
                    }
                    return this;
                }
            };
        }()),

        properties = (function () {
            var camelize = function (string) {
                    return string.replace(/\-\w/g, function (match) {
                        return match.charAt(1).toUpperCase();
                    });
                },
                direction = {
                    firstChild: 'nextSibling',
                    lastChild: 'previousSibling'
                },
                navigate = function (node, traverse) {
                    node = node[traverse];
                    traverse = direction[traverse] || traverse;
                    while (node && node.nodeType !== 1) {
                        node = node[traverse];
                    }
                    return analogue(node);
                },
                setStyle = function (property, value) {
                    property = property === 'float' ? detect.cssFloat : camelize(property);
                    if (property === 'opacity' && !detect.opacity && detect.filters) {
                        this.style.filter = 'alpha(opacity=' + String(value * 100) + ')';
                        if (this.currentStyle && !this.currentStyle.hasLayout) {
                            this.style.zoom = 1;
                        }
                    } else {
                        this.style[property] = value;
                    }
                };
            return {
                addClass: function (value) {
                    var classes = this[0].className.split(' ');
                    if (!this.hasClass(value)) {
                        classes.push(value);
                        this[0].className = classes.join(' ');
                    }
                    return this;
                },
                children: detect.children ? function (selector) {
                    return selector ? makeArray(this[0].children).filter(function () {
                        return analogue.match(this, selector);
                    }) : makeArray(this[0].children);
                } : function (selector) {
                    return makeArray(this[0].childNodes).filter(function () {
                        return this.nodeType === 1 && (selector ? analogue.match(this, selector) : true);
                    });
                },
                firstChild: detect.traversalApi ? function () {
                    return analogue(this[0].firstElementChild);
                } : function () {
                    return navigate(this[0], 'firstChild');
                },
                getStyle: detect.getComputedStyle ? function (property) {
                    property = property === 'float' ? detect.cssFloat : camelize(property);
                    return this[0].style[property] || window.getComputedStyle(this[0], '')[property];
                } : function (property) {
                    property = property === 'float' ? detect.cssFloat : camelize(property);
                    var match,
                        value = this[0].currentStyle ? this[0].currentStyle[property] : null;
                    if (property === 'opacity' && !detect.opacity && detect.filters) {
                        match = (this[0].style.filter || this[0].currentStyle.filter).match(/alpha\s*\(\s*opacity\s*=\s*([\d.]+)\)/i);
                        value = match ? String(match[1] / 100) : '1';
                    } else if (isNaN(parseFloat(value))) {
                        if (/^(height|width)$/i.test(property) && this[0].currentStyle.display !== 'none') {
                            value = this[0]['offset' + property.charAt(0).toUpperCase() + property.slice(1)] + 'px';
                        } else if (/^border(?:top|right|bottom|left)?width|margin|padding/i.test(property)) {
                            value = '0px';
                        }
                    }
                    return this[0].style[property] || value;
                },
                hasClass: function (value) {
                    return this[0].className && (cache.regex.get(value) || cache.regex.set(value, new RegExp('(?:^|\\s)' + escapeRegExp(value) + '(?:\\s|$)'))).test(this[0].className);
                },
                lastChild: detect.traversalApi ? function () {
                    return analogue(this[0].lastElementChild);
                } : function () {
                    return navigate(this[0], 'lastChild');
                },
                nextSibling: detect.traversalApi ? function () {
                    return analogue(this[0].nextElementSibling);
                } : function () {
                    return navigate(this[0], 'nextSibling');
                },
                parent: function (selector) {
                    var parent = this[0].parentNode;
                    if (selector) {
                        while (parent.nodeType !== 9 && !analogue.match(parent, selector)) {
                            parent = parent.parentNode;
                        }
                    }
                    return analogue(parent);
                },
                previousSibling: detect.traversalApi ? function () {
                    return analogue(this[0].previousElementSibling);
                } : function () {
                    return navigate(this[0], 'previousSibling');
                },
                removeClass: function (value) {
                    var classes = this[0].className.split(' '),
                        i;
                    if (this.hasClass(value)) {
                        for (i = classes.length - 1; i > -1; i -= 1) {
                            if (classes[i] === value) {
                                classes.splice(i, 1);
                            }
                        }
                        this[0].className = classes.join(' ');
                    }
                    return this;
                },
                setStyle: function (property, value) {
                    var i;
                    if (typeof property === 'object') {
                        for (i in property) {
                            if (property.hasOwnProperty(i)) {
                                setStyle.call(this[0], i, property[i]);
                            }
                        }
                    } else {
                        setStyle.call(this[0], property, value);
                    }
                    return this;
                },
                toggleClass: function (value) {
                    return this.hasClass(value) ? this.removeClass(value) : this.addClass(value);
                }
            };
        }()),

        nodes = (function () {
            var purge = function (wrapper) {
                    var i,
                        node = wrapper[0];
                    wrapper.children().forEach(function () {
                        analogue(this).remove();
                    });
                    if (wrapper.events) {
                        for (i in wrapper.events) {
                            if (wrapper.events.hasOwnProperty(i) && i !== 'handler') {
                                node[detect.removeEvent](detect.eventPrefix + i, wrapper.events.handler, /^(?:blur|focus)$/i.test(i));
                                cache.events.splice(wrapper.events[i].key, 1);
                            }
                        }
                    }
                    delete cache.wrappers[node.uniqueID];
                    node = null;
                },
                resolve = function (node) {
                    return typeof node === 'string' ? analogue(node)[0] : node[0] || node;
                };
            return {
                appendTo: function (node) {
                    resolve(node).appendChild(this[0]);
                },
                clone: function (deep) {
                    return analogue(this[0].cloneNode(!!deep));
                },
                contains: function (node) {
                    return contains(this[0], resolve(node));
                },
                insertAfter: function (node) {
                    node = resolve(node);
                    if (node.nextSibling) {
                        node.parentNode.insertBefore(this[0], node.nextSibling);
                    } else {
                        node.parentNode.appendChild(this[0]);
                    }
                },
                insertBefore: function (node) {
                    node = resolve(node);
                    node.parentNode.insertBefore(this[0], node);
                },
                prependTo: function (node) {
                    node = resolve(node);
                    if (node.firstChild) {
                        node.insertBefore(this[0], node.firstChild);
                    } else {
                        node.appendChild(this[0]);
                    }
                },
                remove: function () {
                    this[0].parentNode.removeChild(this[0]);
                    purge(this);
                },
                replaceWith: function (node) {
                    this[0].parentNode.replaceChild(resolve(node), this[0]);
                    purge(this);
                }
            };
        }()),

        path = (function (src) {
            return src.replace(/(\?[\w\.]+)$/, '').replace(/((\/)*[\w\.]+)$/, '/').replace(new RegExp('^' + window.location.protocol + '//' + window.location.host), '');
        }(document.getElementsByTagName('script')[0].src)),

        query = (function () {
            var check = {
                    attribute: (function () {
                        var defaults = {
                                checked: 'defaultChecked',
                                selected: 'defaultSelected',
                                value: 'defaultValue'
                            },
                            getAttribute = detect.getAttribute ? function (name) {
                                return this.getAttribute(name) || null;
                            } : function (name) {
                                if (defaults[name] && typeof this[defaults[name]] !== 'undefined') {
                                    return this[defaults[name]] || null;
                                }
                                return methods.get.call(this, name);
                            };
                        return function (element, selector) {
                            var name = selector[2],
                                operator = selector[3],
                                property = getAttribute.call(element, name),
                                value = selector[4];
                            if (!property) {
                                return false;
                            }
                            switch (operator) {
                            case '=':
                                return property === value;
                            case '~':
                                return (cache.regex.get('~' + value) || cache.regex.set('~' + value, new RegExp('(?:^|\\s)' + escapeRegExp(value) + '(?:\\s|$)'))).test(property);
                            case '^':
                                return property.indexOf(value) === 0;
                            case '$':
                                return property.lastIndexOf(value) === (property.length - value.length);
                            case '*':
                                return property.indexOf(value) > -1;
                            case '|':
                                return (cache.regex.get('|' + value) || cache.regex.set('|' + value, new RegExp('^' + escapeRegExp(value) + '(\\-\\w+)*$'))).test(property);
                            }
                            return !operator ? true : false;
                        };
                    }()),
                    className: function (element, classes) {
                        var i,
                            value;
                        for (i = classes.length - 1; i > 0; i -= 1) {
                            value = classes[i];
                            if (!element.className || !(cache.regex.get(value) || cache.regex.set(value, new RegExp('(?:^|\\s)' + escapeRegExp(value) + '(?:\\s|$)'))).test(element.className)) {
                                return false;
                            }
                        }
                        return true;
                    },
                    pass: function () {
                        return true;
                    },
                    tagName: function (element, tag) {
                        return tag === '*' || element.nodeName === tag.toUpperCase();
                    }
                },
                getElements = function (context, tag, combinator, filter, criteria) {
                    var collection = [],
                        element,
                        elements,
                        i,
                        ii,
                        j,
                        jj;
                    filter = filter || check.pass;
                    tag = (tag || '*').toLowerCase();
                    for (i = 0, ii = context.length; i < ii; i += 1) {
                        if (combinator === '>') {
                            element = context[i].firstChild;
                            while (element) {
                                if (element.nodeType === 1 && check.tagName(element, tag) && filter(element, criteria)) {
                                    collection.push(element);
                                }
                                element = element.nextSibling;
                            }
                        } else if (combinator === '+') {
                            element = context[i].nextSibling;
                            while (element) {
                                if (element.nodeType === 1) {
                                    if (check.tagName(element, tag) && filter(element, criteria)) {
                                        collection.push(element);
                                    }
                                    break;
                                }
                                element = element.nextSibling;
                            }
                        } else {
                            elements = context[i].getElementsByTagName(tag);
                            for (j = 0, jj = elements.length; j < jj; j += 1) {
                                element = elements[j];
                                if (element.nodeType === 1 && filter(element, criteria)) {
                                    collection.push(element);
                                }
                            }
                        }
                    }
                    return collection;
                },
                parse = function (context, selector) {
                    var combinator,
                        i,
                        ii,
                        match,
                        token,
                        tokens = selector.replace(/\s*(>|\+)\s*/g, ' $1').split(/\s+/);
                    context = [context];
                    if ((match = /^#([\w\u00c0-\uFFFF\-]+)$/.exec(tokens[0])) !== null) {
                        context = [getElementById(match[1])];
                    }
                    for (i = 0, ii = tokens.length; i < ii; i += 1) {
                        token = tokens[i];
                        if ((match = /^(>|\+)/.exec(token)) !== null) {
                            combinator = match[1];
                            token = token.replace(combinator, '');
                        }
                        if ((match = /^([\w]+)*#([\w\u00c0-\uFFFF\-]+)$/.exec(token)) !== null) {
                            context = getElementById(match[2]);
                            if (!context || (match[1] && context.nodeName !== match[1].toUpperCase())) {
                                return [];
                            }
                            context = [context];
                        } else if ((match = /^([\w]+)*\[([\w\u00c0-\uFFFF\-]+)(?:([=~|\^$*]?)=?['"]?([\s\w\u00c0-\uFFFF\-\/?&=:.()!,@#%<>{}$*\^]+)["']?)?\]$/.exec(token)) !== null) {
                            context = getElements(context, match[1], combinator, check.attribute, match);
                        } else if (token.indexOf('.') > -1) {
                            match = token.split('.');
                            context = getElements(context, match[0], combinator, check.className, match);
                        } else {
                            context = getElements(context, token, combinator);
                        }
                    }
                    return context;
                },
                uniqueSort = (function () {
                    var documentOrder = root.compareDocumentPosition ? function (a, b) {
                            /*jslint bitwise: true*/
                            return a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
                        } : root.sourceIndex ? function (a, b) {
                            return a.sourceIndex - b.sourceIndex;
                        } : document.createRange ? function (a, b) {
                            var aRange = a.ownerDocument.createRange(),
                                bRange = b.ownerDocument.createRange();
                            aRange.setStart(a, 0);
                            aRange.setEnd(a, 0);
                            bRange.setStart(b, 0);
                            bRange.setEnd(b, 0);
                            return aRange.compareBoundaryPoints(window.Range.START_TO_END, bRange);
                        } : null;
                    return function (collection, context) {
                        var i = 0,
                            unique = new DOMArray();
                        collection.sort(documentOrder);
                        while (collection[i]) {
                            if (collection[i] === collection[i - 1]) {
                                collection.splice(i -= 1, 1);
                            } else if (context === document || contains(context, collection[i])) {
                                unique.push(collection[i]);
                            }
                            i += 1;
                        }
                        return unique;
                    };
                }());
            return {
                match: function (element, selector) {
                    if (detect.matchesSelector && !detect.querySelector.test(selector)) {
                        try {
                            return element[detect.matchesSelector](selector);
                        } catch (e) {}
                    }
                    return query.select(document, selector).indexOf(element) > -1;
                },
                select: function (context, selector) {
                    if (!detect.querySelector.test(selector)) {
                        try {
                            return makeArray(context.querySelectorAll(selector));
                        } catch (e) {}
                    }
                    var collection = [],
                        i,
                        ii,
                        groups = selector.replace(/\s*,\s*/g, ',').split(',');
                    for (i = 0, ii = groups.length; i < ii; i += 1) {
                        push.apply(collection, parse(context, groups[i]));
                    }
                    return uniqueSort(collection, context);
                }
            };
        }()),

        uniqueId = typeof root.uniqueID !== 'undefined' ? function (node) {
            return node.uniqueID;
        } : function (node) {
            var id = (cache.guid += 1) + '_' + node.nodeName;
            node.uniqueID = id;
            return id;
        },

        wrapper = function (element) {
            var wrap = new DOMWrapper(element);
            cache.wrappers[uniqueId(element)] = wrap;
            return wrap;
        },

        versioning = [1, String(build.getFullYear()).slice(2), String((build.getMonth() + 1) / 100).slice(2)],

        $ = (function () {
            function parse(selector, context) {
                var match,
                    node;
                context = context ? parse(context)[0] : document;
                if (!selector) {
                    return new DOMArray();
                }
                if (selector instanceof DOMWrapper || selector instanceof DOMArray) {
                    return selector;
                }
                if (selector === window) {
                    return cache.wrappers.window;
                }
                if (selector === document) {
                    return cache.wrappers.document;
                }
                if (selector.nodeType) {
                    node = selector;
                } else if (selector === 'body') {
                    node = document.body;
                } else if (selector === 'head') {
                    node = document.head || document.getElementsByTagName('head')[0];
                } else if (selector === 'html') {
                    node = root;
                } else if ((match = /^#([\w\u00c0-\uFFFF\-]+)$/.exec(selector)) !== null) {
                    node = getElementById(match[1]);
                    if (!node || (context !== document && !contains(context, node))) {
                        return new DOMArray();
                    }
                }
                if (node) {
                    if (node.uniqueID && cache.wrappers[node.uniqueID]) {
                        return cache.wrappers[node.uniqueID];
                    }
                    return wrapper(node);
                }
                if (/^(?:<[\s\w\u00c0-\uFFFF\-\/?&=:.()!,@#%<>{}$*\^'"]+>)$/.test(selector)) {
                    if ((match = /^<(\w+)\s*\/?>(?:<\/\1>)?$/.exec(selector)) !== null) {
                        return wrapper(document.createElement(match[1]));
                    }
                    return new DOMFragment(selector);
                }
                if ((match = /^\.([\w\u00c0-\uFFFF\-]+)$/.exec(selector)) !== null && detect.getElementsByClassName) {
                    return makeArray(context.getElementsByClassName(match[1]));
                }
                if (/^(?:[\w]+)$/.test(selector)) {
                    return makeArray(context.getElementsByTagName(selector));
                }
                return query.select(context, selector);
            }
            return function (selector, context) {
                return parse(selector, context);
            };
        }());

    DOMArray.prototype = [];
    (function (test) {
        test.push(1);
        if (test.length !== 1) {
            DOMArray = Array;
        }
    }(new DOMArray()));
    (function (prototype) {
        prototype.each = prototype.forEach = function (iterator, context) {
            var i = 0,
                ii = this.length;
            while (i < ii) {
                if (this.hasOwnProperty(i) && iterator.call(context || this[i], this[i], i, this) === false) {
                    break;
                }
                i += 1;
            }
        };
        prototype.filter = function (iterator, context) {
            var i = 0,
                ii = this.length,
                result = new DOMArray();
            while (i < ii) {
                if (this.hasOwnProperty(i) && iterator.call(context || this[i], this[i], i, this)) {
                    result.push(this[i]);
                }
                i += 1;
            }
            return result;
        };
        prototype.first = function () {
            return analogue(this[0]);
        };
        prototype.index = function (i) {
            return analogue(this[i]);
        };
        prototype.last = function () {
            return analogue(this[this.length - 1]);
        };
    }(DOMArray.prototype));

    extend(DOMFragment.prototype, {
        appendTo: nodes.appendTo,
        insertAfter: nodes.insertAfter,
        insertBefore: nodes.insertBefore,
        prependTo: nodes.prependTo
    });

    extend(methods, events);
    (function (prototype) {
        extend(prototype, methods);
        extend(prototype, nodes);
        extend(prototype, properties);
    }(DOMWrapper.prototype));

    cache.wrappers.window = extend({
        0: window,
        getDimensions: typeof window.innerWidth === 'number' ? function () {
            return {
                height: window.innerHeight,
                scroll: {
                    x: root.scrollWidth,
                    y: root.scrollHeight
                },
                width: window.innerWidth
            };
        } : function () {
            var height = root.offsetHeight,
                width = root.offsetWidth,
                x = root.scrollWidth,
                y = root.scrollHeight;
            return {
                height: height,
                scroll: {
                    x: x > width ? x : width,
                    y: y > height ? y : height
                },
                width: width
            };
        },
        getScrollOffsets: function () {
            return {
                x: window.pageXOffset || root.scrollLeft || 0,
                y: window.pageYOffset || root.scrollTop || 0
            };
        },
        length: 1
    }, methods);

    cache.wrappers.document = extend({
        0: document,
        length: 1,
        loadScript: function (source, callback) {
            if (!document.addEventListener && !domContentLoaded && !callback) {
                this[0].write('<script src="' + source + '" type="text/javascript"></script>');
            } else {
                var loaded = false,
                    script = analogue('<script/>').set({
                        async: true,
                        src: source,
                        type: 'text/javascript'
                    });
                if (callback && typeof callback === 'function') {
                    script[0].onload = script[0].onreadystatechange = function () {
                        if ((this.readyState && /in/.test(this.readyState)) || loaded) {
                            return;
                        }
                        loaded = true;
                        callback();
                        this.onload = this.onreadystatechange = null;
                    };
                    window.setTimeout(function () {
                        if (!loaded) {
                            loaded = true;
                            callback();
                        }
                    }, 5E3);
                }
                script.insertBefore(analogue('script')[0]);
            }
            return this;
        },
        ready: function (listener) {
            if (!domContentLoaded) {
                events.addEvent.call(this, 'dataavailable', listener);
            } else {
                listener.apply(this, arguments);
            }
            return this;
        }
    }, methods);

    (function () {
        var div = document.createElement('div'),
            doScroll = function () {
                try {
                    div.doScroll();
                    div = null;
                    return true;
                } catch (e) {}
                return false;
            },
            init = function (event) {
                if (event.type) {
                    if (event.type === 'readystatechange' && document.readyState !== 'complete') {
                        return;
                    }
                    (event.type === 'load' ? window : document)[detect.removeEvent](detect.eventPrefix + event.type, init, false);
                }
                if (domContentLoaded === false) {
                    domContentLoaded = true;
                    analogue(document).triggerEvent('dataavailable');
                }
            },
            poll = function (check) {
                window.setTimeout(check, 10);
            };
        if (document.readyState === 'complete') {
            init('readyState');
        } else {
            if (div.doScroll && !doScroll()) {
                poll(function check() {
                    return doScroll() ? init('doScroll') : poll(check);
                });
            } else {
                poll(function check() {
                    return (/loaded|complete/i.test(document.readyState)) ? init('readyState') : poll(check);
                });
            }
            'load DOMContentLoaded readystatechange'.replace(/\w+/g, function (type) {
                (type === 'load' ? window : document)[detect.addEvent](detect.eventPrefix + type, init, false);
            });
        }
    }());

    if (root.addEventListener) {
        if (!document.readyState) {
            document.addEventListener('DOMContentLoaded', function cleanup() {
                document.removeEventListener('DOMContentLoaded', cleanup, false);
                document.readyState = 'complete';
            }, false);
            document.readyState = 'loading';
        }
    } else if (root.attachEvent && detect.msie) {
        cache.wrappers.document.loadScript(path + 'Analogue.MSIE.js', false);
        window.attachEvent('onunload', function cleanup() {
            var i;
            window.detachEvent('onunload', cleanup);
            for (i = cache.events.length - 1; i > -1; i -= 1) {
                cache.events[i][0].detachEvent('on' + cache.events[i][1], cache.events[i][2]);
            }
        });
    }

    return (window.$ = extend($, {
        detect: detect,
        extend: function (plugin) {
            if (typeof plugin.init === 'function' && plugin.init()) {
                delete plugin.init;
            }
            extend(DOMWrapper.prototype, plugin);
        },
        noConflict: function () {
            window.$ = dollar;
            return this;
        },
        match: query.match,
        path: path,
        version: versioning.join('.') + ' (' + parseInt(build.valueOf() / 1E3, 10) + ')'
    }));
}(this.document, [].push, this.document.documentElement, [].slice, this));